home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / recent / iib122.lha / IIB / Threads / Additional / IARexx.lha / Twirl.irx < prev    next >
Text File  |  1997-09-18  |  6KB  |  219 lines

  1.  
  2. /*-----------------------------------------------------------------------*/
  3. /* ARexx script for Amiga Imagine 5.0                                    */
  4. /* Creates a planisphere only composed of twirling longitudes            */
  5. /*                                                                       */
  6. /* Author: Anh Tu NGUYEN TRONG                                           */
  7. /* Email: atnt@diaf.fr                                                   */
  8. /*                                                                       */
  9. /* Requirements                                                          */
  10. /* - Workbench 2.04 or higher                                            */
  11. /* - rexxreqtools.library 1.3 or higher                                  */
  12. /* - reqtools.library 38 or higher                                       */
  13. /* - Imagine 5.0                                                         */
  14. /*                                                                       */
  15. /* The rexxreqtools and reqtools libraries can be retrieved from Aminet. */
  16. /* rexxreqtools is an ARexx interface to reqtools.                       */
  17. /*                                                                       */
  18. /* The script can be run without the rexxreqtools library:               */
  19. /* just remove the delimited section. You can edit the source to         */
  20. /* change the parameters.                                                */
  21. /*                                                                       */
  22. /* Warning                                                               */
  23. /* the ARexx script doesn't check the validity of the three numbers.     */
  24. /*                                                                       */
  25. /* Usage                                                                 */
  26. /* - Imagine 5.0 should be already launched                              */
  27. /* - From a Shell window: rx twirl.irx                                   */
  28. /*                                                                       */
  29. /* Three numbers have to be entered through requesters:                  */
  30. /* - radius                 (default value: 100) (must be an even value) */
  31. /* - circle_sections_number (default value: 24)  (must be an even value) */
  32. /* - sections_number        (default value: 12)  (must be an even value) */
  33. /*                                                                       */
  34. /* Note                                                                  */
  35. /* By modifiying the source, you can generate a sphere with the          */
  36. /* half portion filled.                                                  */
  37. /*-----------------------------------------------------------------------*/
  38.  
  39. /*******************************************************************/
  40.  
  41. /* Beginning of twirl.irx */
  42.  
  43.  
  44. /* Sphere's parameters that can be altered manually if the */
  45. /* rexxreqtools library is not used.                       */
  46.  
  47. radius = 100
  48. circle_sections_number = 24
  49. sections_number = 12
  50.  
  51.  
  52. /* --8<-- Start of rexxreqtools part which may be removed ----- */
  53.  
  54. call addlib("rexxreqtools.library", 0, -30, 0)
  55.  
  56.  
  57. radius_box_title = "Radius"
  58. radius_box_message = "Sphere radius ?"
  59.  
  60. circle_sections_box_title = "Circle sections"
  61. circle_sections_box_message = "Number of circle sections ?"
  62.  
  63. vertical_sections_box_title = "Vertical sections"
  64. vertical_sections_box_message = "Number of vertical sections ?"
  65.  
  66. buttons_labels="_OK|_Abort script"
  67.  
  68.  
  69. radius = rtgetlong(radius,,
  70.                    radius_box_message,,
  71.                    radius_box_title,,
  72.                    buttons_labels,,
  73.                    ,,
  74.                    code_retour)
  75.  
  76. if radius == "" then
  77.   exit
  78.  
  79.  
  80. circle_sections_number = rtgetlong(circle_sections_number,,
  81.                                    circle_sections_box_message,,
  82.                                    circle_sections_box_title,,
  83.                                    buttons_labels,,
  84.                                    ,,
  85.                                    code_retour)
  86.  
  87. if circle_sections_number == "" then
  88.   exit
  89.  
  90.  
  91. sections_number = rtgetlong(sections_number,,
  92.                             vertical_sections_box_message,,
  93.                             vertical_sections_box_title,,
  94.                             buttons_labels,,
  95.                             ,,
  96.                             code_retour)
  97.  
  98. if sections_number == "" then
  99.   exit
  100.  
  101. /* --8<-- End of rexxreqtools part which may be removed ----- */
  102.  
  103.  
  104. address "Imagine.1"
  105.  
  106.  
  107. displayrexxptr on
  108.  
  109. detaileditor
  110. objectmode
  111.  
  112. addsphere radius circle_sections_number sections_number 'OFF'
  113.  
  114. pick select
  115.  
  116. /* Number of faces computation */
  117.  
  118. faces_number = ((sections_number - 2) * circle_sections_number * 2) + (2 * circle_sections_number)
  119.  
  120.  
  121. /* Computation of the number of faces pairs by circumference */
  122.  
  123. pairs_number = circle_sections_number / 2
  124.  
  125.  
  126. facemode
  127. multipickon
  128.  
  129.  
  130. /* Selection of the faces of the first circumference */
  131. /* Particular case because of 2 times less faces     */
  132.  
  133. numero = 1
  134.  
  135. do until numero >= (circle_sections_number + 1)
  136.   pick numero
  137.   numero = numero + 2
  138. end
  139.  
  140.  
  141. /* Faces selection */
  142.  
  143. numero = circle_sections_number + 1
  144. pairs_counter = 0
  145.  
  146. even_increment = 3
  147. odd_increment = 3
  148.  
  149.  
  150. do until (numero >= (faces_number - circle_sections_number))
  151.  
  152.  
  153.  pick numero
  154.  
  155.  numero = numero + 1
  156.  pick numero
  157.  pairs_counter = pairs_counter + 1
  158.  
  159.  
  160.  if (pairs_counter = pairs_number) then
  161.    do
  162.  
  163.      numero = numero + even_increment
  164.      even_increment = even_increment - 1
  165.  
  166.      pairs_counter = 0.5
  167.      pick numero
  168.      numero = numero + 3
  169.    end
  170.  
  171.  else
  172.    do
  173.     if (pairs_counter = (pairs_number - 0.5)) then
  174.       do
  175.         numero = numero + odd_increment
  176.  
  177.         /* Strange but it works !!!*/
  178.         even_increment = odd_increment - 1
  179.  
  180.         pick numero
  181.         pairs_counter = 0
  182.         numero = numero + 2
  183.       end
  184.  
  185.     else
  186.       do
  187.         numero = numero + 3
  188.       end
  189.  
  190.    end
  191.  
  192. end
  193.  
  194.  
  195. /* Selection of the faces of the last circumference */
  196. /* Particular case because of 2 times less faces    */
  197.  
  198. numero = faces_number - circle_sections_number
  199.  
  200. do until numero > faces_number
  201.   pick numero
  202.   numero = numero + 2
  203. end
  204.  
  205.  
  206. /* Deletion of selected faces */
  207. delete
  208.  
  209. multipickoff
  210. objectmode
  211.  
  212. displayrexxptr off
  213. beep
  214. exit
  215.  
  216. /* End of twirl.irx */
  217.  
  218. /*******************************************************************/
  219.